package com.leyou.page.Controller;

import com.leyou.page.Service.PageService;
import com.leyou.page.Vo.SpuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/page")
public class PageController {

    @Autowired
    private PageService pageService;

    //查询spu表
    @GetMapping("spu/{spuId}")
    public ResponseEntity<String> querySpuById(@PathVariable("spuId") Long spuId){
       String spuVO = pageService.querySpuById(spuId);
       return ResponseEntity.ok(spuVO);
    }

    //查询sku表
    @GetMapping("sku/{spuId}")
    public ResponseEntity<String> querySkuById(@PathVariable("spuId") Long spuId){
        String sku = pageService.querySkuById(spuId);
        return ResponseEntity.ok(sku);
    }

    //查询detail表
    @GetMapping("detail/{spuId}")
    public ResponseEntity<String> queryDetailById(@PathVariable("spuId") Long spuId){
        String detail = pageService.queryDetailById(spuId);
        return ResponseEntity.ok(detail);
    }

    //查询品牌id及名字
    @GetMapping("brand/{brandId}")
    public ResponseEntity<String>  queryBrandById(@PathVariable("brandId") Long brandId){
       String brandVo = pageService.queryBrandById(brandId);
       return ResponseEntity.ok(brandVo);
    }

    //查询分类及名字
    @GetMapping("/category")
        public ResponseEntity<String> queryCategoryById(@RequestParam("ids") List<Long> Ids){
       String categoryVo = pageService.queryCategoryById(Ids);
       return ResponseEntity.ok(categoryVo);
    }

    //查询规格组及参数
    @GetMapping("group/{categoryId}")
    public ResponseEntity<String> queryGroupAndParamById(@PathVariable("categoryId") Long categoryId){
        String groupVo = pageService.queryGroupAndParamById(categoryId);
        return ResponseEntity.ok(groupVo);
    }


}
